package org.wings27.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.wings27.interfaces.IProblemPreprocessService;
import org.wings27.interfaces.IProblemService;

import java.util.Map;

/**
 * Project Name: answerIt
 * Date Created: 2013/11/19 15:19
 *
 * @author wings
 */
public class ProblemPreprocess implements IProblemPreprocessService {
    @Autowired
    private IProblemService problemService;
    private Map config;

    @Override
    public void process(IProblemService raw) {
        String problem = raw.getProblem();
        String blankSymbol = config.get("BLANK_SYMBOL").toString();  //todo: use regexp.
        problemService.setBeforeBlank(problem.substring(0, problem.indexOf(blankSymbol)));
        problemService.setAfterBlank(problem.substring(problem.indexOf(blankSymbol) + blankSymbol.length()));
        problemService.setChoices(null);  //todo: to be implemented.
    }

    public Map getConfig() {
        return config;
    }

    public void setConfig(Map config) {
        this.config = config;
    }

    public void setProblemService(IProblemService problemService) {
        this.problemService = problemService;
    }

    public IProblemService getProblemService() {
        return problemService;
    }
}
